<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <#include "../common/header.ftl">
</head>
<script>
    $(function () {
        $('#pagination').twbsPagination({
            totalPages:${result.pages},
            startPage:${result.pageNum},
            visiblePages:${result.pageSize},
            first:"首页",
            prev:"上一页",
            next:"下一页",
            last:"莫邪",

            onPageClick:function(event,page){
                $('#currentPage').val(page);
                $("#searchForm").submit();
            }
        });

        $(".addBtn").click(function () {
            $("#editForm").clearForm()
            $("#systemDictionaryId").val($("#parentId").val())
            $("#myModal").modal('show')
        })

        $(".editBtn").click(function () {
            var data = $(this).data("jsonstr")
            $("#dictionaryItemId").val(data.id)
            $("#title").val(data.title)
            $("#sequence").val(data.sequence)
            $("#myModal").modal('show')
        })
        
        $(".saveBtn").click(function () {
           $("#editForm").ajaxSubmit(function (data) {
               showMessager(data);
           })
        })
        
        $(".dic").click(function () {
            var id = $(this).data("did");
            $("#parentId").val(id);
            $("#searchForm").submit();
        })

        $(".in li.${qo.parentId}").addClass("active");

    })



    
</script>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">字典管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/dictionaryItem/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <input type="hidden" name="parentId" id="parentId" value="${qo.parentId}">
                <a  class="btn btn-success addBtn">添加</a>
            </form>
            <div class="row">
                <div class="col-md-3">
                    <ul id="menu" class="list-group">
                        <li class="list-group-item">
                            <a href="#" data-toggle="collapse" data-target="#shuju_detail">
                                <span>数据字典分组</span>
                            </a>
                            <ul class="in" id="shuju_detail">
                                <#list dictionarys as d>
                                    <li class="${d.id}"><a class="dic" data-did="${d.id}">${d.title}</a></li>
                                </#list>
                            </ul>
                        </li>
                    </ul>
                </div>
                <div class="col-md-9">
                    <table class="table table-striped table-hover" >
                        <thead>
                        <tr>
                            <th>编号</th>
                            <th>名称</th>
                            <th>序列</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                    <#list result.list as entity>
                        <tr>
                            <td>${entity_index}</td>
                            <td>${(entity.title)!}</td>
                            <td>${(entity.sequence)!}</td>
                            <td>
                                <@shiro.hasPermission name="dictionaryItem:saveOrUpdate">
                                    <a class="btn btn-info btn-xs editBtn" data-jsonstr='${(entity.jsonString)!}'>
                                        <span class="glyphicon glyphicon-pencil "></span>编辑
                                    </a>
                                </@shiro.hasPermission>

                            </td>
                        </tr>
                    </#list>
                    </table>
                    <div style="text-align: center;">
                        <ul id="pagination" class="pagination"></ul>
                    </div>
                </div>
            </div>



        </div>
    </div>
</div>

<div class="modal fade " tabindex="-1" id="myModal" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">字典明细编辑/保存</h4>
            </div>
                <div class="modal-body">
                    <form class="form-horizontal" action="/dictionaryItem/saveOrUpdate.do" method="post" id="editForm">
                        <input type="hidden" id="dictionaryItemId" name="id">
                        <input type="hidden" id="systemDictionaryId" name="parentId" value="${(entity.parentId)!}">
                        <div class="form-group" >
                            <label for="title" class="col-sm-3 control-label">名称：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" id="title" name="title" value="${(entity.title)!}" placeholder="请输入字典明细名称">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="sequence" class="col-sm-3 control-label">序列：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" id="sequence" name="sequence" value="${(entity.sequence)!}" placeholder="请输入序列">
                            </div>
                        </div>
                    </form>
                </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary saveBtn" >确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


</body>
</html>